home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 1
/
Nebula One.iso
/
Utilities
/
Converters
/
Convert_PICT
/
Source
/
CommentedPSCode
/
Lines
< prev
next >
Wrap
Text File
|
1995-06-12
|
4KB
|
165 lines
%BEGIN Lines
% Copyright (C) 1993 David John Burrowes
% Distributed under terms of GNU General Public License.
% See COPYING.text in Convert PICT's CommentedPSCode for a copy
%%%%%%%%%%%%%
% Define the current pict point used for drawing lines
%%%%%%%%%%%%%
/currentX 0 def
/currentY 0 def
%%%%%%%%%%%%%
% Name: PICTline
% Syntax: x1 y1 x2 y2 PICTline -
% About: Draws a line from first to second point, using current pattern,
% width&height. This is drawn in the Mac way, with the pen down
% and right of coordinate. pen size of 1 is stroked so it looks
% better (but not placed as accurately)
%%%%%%%%%%%%%
/PICTline
{
/endY exch def
/endX exch def
/startY exch def
/startX exch def
%
% Only draw if pensize > 0
%
penHeight 0 gt
penWidth 0 gt
and
{
gsave
penPattern usePattern
newpath
%
% If pensize is 1, do simple display.
%
penHeight 1 eq
penWidth 1 eq
and
{
startX startY moveto
endX endY lineto
stroke
}
{
%
% Draw the line as a multi-sided shape. compute corner
% coords based on which direction it is drawn in.
%
endY startY lt
{
endX startX gt
{
startX startY moveto
endX endY lineto
endX penWidth add endY lineto
endX penWidth add endY penHeight add lineto
startX penWidth add startY penHeight add lineto
startX startY penHeight add lineto
}
{
startX penWidth add startY moveto
endX penWidth add endY lineto
endX endY lineto
endX endY penHeight add lineto
startX startY penHeight add lineto
startX penWidth add startY penHeight add lineto
}
ifelse
}
{
endX startX gt
{
startX startY moveto
startX penWidth add startY lineto
endX penWidth add endY lineto
endX penWidth add endY penHeight add lineto
endX endY penHeight add lineto
startX startY penHeight add lineto
}
{
startX startY moveto
endX endY lineto
endX endY penHeight add lineto
endX penWidth add endY penHeight add lineto
startX penWidth add startY penHeight add lineto
startX penWidth add startY lineto
}
ifelse
}
ifelse
closepath
fill
} % End pensize = 1.
ifelse
grestore
} % End pensize >0
if
} def
%%%%%%%%%%%%%
% Name: line [0020]
% Syntax: x1 y1 x2 y2 line -
% About: Given a pair of x,y coordinates, draw a pict-style line from
% the first to the last, and store the current point.
%%%%%%%%%%%%%
/line
{
/endY exch def
/endX exch def
/startY exch def
/startX exch def
startX startY endX endY PICTline
/currentX endX def
/currentY endY def
} def
%%%%%%%%%%%%%
% Name: LineFrom [0021]
% Syntax: x2 y2 line -
% About: Draws a line from the current pon to the x and y coord passed.
%%%%%%%%%%%%%
/lineFrom
{
/endY exch def
/endX exch def
currentX currentY endX endY line
} def
%%%%%%%%%%%%%
% Name: line [0022]
% Syntax: x1 y1 dx dy line -
% About: Draws a line from pt 1 to pt 1' (1' = 1 + dx,dy)
%%%%%%%%%%%%%
/shortLine
{
/dy exch def
/dx exch def
/startY exch def
/startX exch def
startX startY startX dx add startY dy add line
} def
%%%%%%%%%%%%%
% Name: ShortLineFrom [0023]
% Syntax: dx dy ShortLineFrom -
% About: Draws a line the current to the pased offset from it
%%%%%%%%%%%%%
/shortLineFrom
{
/dy exch def
/dx exch def
currentX currentY currentX dx add currentY dy add line
} def
%END Lines